import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:situation/app/router/router_name.dart';
import 'package:situation/app/theme/app_theme.dart';
import 'package:situation/app/theme/gaps.dart';
import 'package:situation/domain/user/task.dart';
import 'package:situation/resources/assets.dart';
import 'package:situation/widgets/mk_load_image.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

class AppTaskCard extends StatefulWidget {

  final Task task;

  const AppTaskCard({super.key, required this.task});

  @override
  State<AppTaskCard> createState() => _AppTaskCardState();
}

class _AppTaskCardState extends State<AppTaskCard> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Get.toNamed(RouterName.taskDetail, arguments: widget.task.id);
      },
      child: Container(
        margin: EdgeInsets.all( 12),
        decoration: BoxDecoration(
          color: Colors.white,
            boxShadow: [
              BoxShadow(
                  color: Color(0xFFD9D9D9),
                  offset: Offset(0, 0),
                  blurRadius: 4,
                  spreadRadius: 0)
            ],
            borderRadius: AppTheme.iBorderRadius),
        clipBehavior: Clip.antiAlias,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              decoration: BoxDecoration(color: Color(0xFFFFBB95)),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: EdgeInsets.only(left: AppTheme.iDefaultPadding,top: 8,bottom: 8),
                        child: Text(
                          '${widget.task.title}',
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 16,
                              fontWeight: FontWeight.bold),
                        ),
                      ),
                      TDTag(
                        '${widget.task.statusStr}',
                        size: TDTagSize.small,
                        theme: TDTagTheme.danger,
                      ),
                    ],
                  ),
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.all( AppTheme.iDefaultPadding),
              decoration: BoxDecoration(color: Colors.white),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Row(
                    children: [
                      Text("${widget.task.address}"),
                    ],
                  ),
                  Gaps.vGap4,
                  Text(
                    '${widget.task.info}',
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(fontSize: 12,color: Colors.black.withOpacity(0.5)),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
